package com.clz.appdesign.myapp.anim;

import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.content.Context;
import android.widget.TextView;

import com.clz.appdesign.appdependence.base.BaseActivity;
import com.clz.appdesign.myapp.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ObjectAnimatiorActivity extends BaseActivity {


    @BindView(R.id.point_view)
    PointView mPointView;
    @BindView(R.id.tv_test)
    TextView mTvTest;

    @Override
    public void initToolbar() {
        ButterKnife.bind(this);
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {

    }

    @Override
    public void doBusiness(Context mContext) {

    }

    @Override
    public int layoutResID() {
        return R.layout.activity_object_animatior;
    }


    @OnClick(R.id.btn_start_anim)
    public void onViewClicked() {
       // doPointViewAnimation();
        doTvRotationAnimation();
    }

    private void doTvRotationAnimation() {
        PropertyValuesHolder rotationHolder=PropertyValuesHolder.ofFloat("rotation",60f, -60f, 40f, -40f, -20f, 20f, 10f, -10f, 0f);
        PropertyValuesHolder colorHolder=PropertyValuesHolder.ofInt("BackgroundColor", 0xffffffff, 0xffff00ff, 0xffffff00, 0xffffffff);
        ObjectAnimator objectAnimator=ObjectAnimator.ofPropertyValuesHolder(mTvTest,rotationHolder,colorHolder);
        objectAnimator.setDuration(2000);
        objectAnimator.setRepeatCount(ValueAnimator.INFINITE);
        objectAnimator.setRepeatMode(ValueAnimator.REVERSE);
        objectAnimator.start();
    }

    private void doPointViewAnimation() {
        ObjectAnimator objectAnimator = ObjectAnimator.ofInt(mPointView, "PointRadius", 0, 300, 100);
        objectAnimator.setDuration(2000);
        objectAnimator.setRepeatCount(ValueAnimator.INFINITE);
        objectAnimator.setRepeatMode(ValueAnimator.REVERSE);
        objectAnimator.start();
    }

}
